package choco.integer.search;

import choco.AbstractProblem;
import choco.integer.IntDomainVar;
/** History:
 * 2007-12-07 : FR_1873619 CPRU: DomOverDeg+DomOverWDeg
 * */
public final class DomOverFailureDeg extends DoubleHeuristicIntVarSelector {
    public DomOverFailureDeg(AbstractProblem pb) {
        super(pb);
    }

    public DomOverFailureDeg(AbstractProblem pb, IntDomainVar[] vs) {
        super(pb);
        vars = vs;
    }

    public double getHeuristic(IntDomainVar v) {
        int dsize = v.getDomainSize();
        int deg = v.getNbConstraints();
        int weight = v.getNbFailure();
        if (deg == 0)
            return Double.POSITIVE_INFINITY;
        else
            return (double) dsize / ((double) deg * (double) weight);
    }
}
